package datastructure;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author XY
 * @version 1.0
 * @date 2022/2/10 9:32
 * @Description
 */
public class Leet242 {

    public static boolean isAnagram(String s, String t) {
        Map<String, Integer> count = count(s);
        Map<String, Integer> count1 = count(t);

        return count1.equals(count);
    }

    public static Map<String,Integer> count(String s){
        char[] chars = s.toCharArray();
        String ditinct = "";
        for (int i = 0; i < chars.length; i++) {
            if(!ditinct.contains((chars[i])+"")){
                ditinct+=(chars[i]+"");
            }
        }
        char[] chars1 = ditinct.toCharArray();
        Map<String,Integer> map = new HashMap<>();
        for (int i = 0; i < chars1.length; i++) {
            int num = 0;
            for (int j = 0; j < chars.length; j++) {
                if(chars[j]==chars1[i]){
                    num++;
                }
            }
            map.put(chars1[i]+"",num);
        }
        return map;
    }

    public static void main(String[] args) {
//        System.out.println(count("dgqztusjuu"));
        System.out.println(count("dqugjzutsu"));

//        System.out.println(isAnagram("dgqztusjuu","dqugjzutsu"));
    }
}
